#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "Joseph.c"


int main(){

	int a[]={3,1,7,2,4,8,4},i=1;
	LinkList la,p;
	InitList(&la,a,7);

	p=la->next;
	
	while(p!=NULL && i++<8){
		printf("%d\n",p->data);
		p=p->next;
	}

	//*********约瑟夫环程序*************************
	//
	int m=20;
	ElemSet e,x;
	srand(time(NULL));

	i=GetElem(la,m,&e);
	m=e;
	ListDelete(la,i,&x);
	printf("%d(%d),",i,e);
	while(ListLength(la)!=1){
		p=GetPointer(la,i);
		i=GetElem(p,m,&e);
		m=e;
		ListDelete(la,i,&x);
		printf("%d(%d),",i,e);
	}
	p=GetPointer(la,i);
	i=GetElem(p,m,&e);
	printf("%d(%d),",i,e);


	DestoryList(la);

}

